<?php
/**
 * Dependency parser service
 *
 * PHP version 5
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id:$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
require_once 'W/W.php';
require_once 'W/Dependency/Parser/Abstract.php';
/**
 * Dependency parser service
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
class W_Dependency_Parser_Service extends W_Dependency_Parser_Abstract
{
    /**
     * Parsers the specified file
     *
     * @param $data
     *
     * @return array list of events to fire
     */
    public function parse($data)
    {
        $item = $data['item'];
        if (false === $this->getAdapter()->isExistingItem($item)) {
            throw new RuntimeException("Item '$item' does not exist");
        }
        unset($data['item']);
        return $this->getAdapter()->parseTokenizedItem(
            $this->getAdapter()->tokenizeItemContent(
                $this->getAdapter()->readItem($item)),
                $item,
                $data);
    }
}